package com.ms.oschina.fragment;

import java.io.IOException;
import java.util.List;

import android.view.ViewTreeObserver.OnGlobalLayoutListener;

import com.ms.oschina.adapter.FriendAdapter;
import com.ms.oschina.adapter.PageIndexListAdapter;
import com.ms.oschina.api.remote.OsChinaApi;
import com.ms.oschina.base.BaseListFragment;
import com.ms.oschina.bean.Favorite;
import com.ms.oschina.bean.Friend;
import com.ms.oschina.bean.FriendsList;

public class FollowInfoFragment extends BaseListFragment<Friend> {

	private FriendAdapter adapter;

	@Override
	public PageIndexListAdapter<Friend> getAdapter() {
		adapter = new FriendAdapter(getListView(), getNetData(), true);
		int mark = getMark();
		adapter.setMark(mark);
		return adapter;
	}


	@Override
	public List<Friend> getNetData(int pageIndex) throws IOException {
		int mark = getMark();
		switch (mark) {
		case FriendsList.TYPE_FOLLOWER:
			return OsChinaApi.getFriendInfo(pageIndex,
					FriendsList.TYPE_FOLLOWER);
		case FriendsList.TYPE_FANS:
			return OsChinaApi.getFriendInfo(pageIndex, FriendsList.TYPE_FANS);
		default:
			return null;
		}
	}
}
